Returns the value of an index from a JSONArray or a default value if the index is out of range.
Syntax
JSONArrayGetValue("JSON", Index, DefaultReturnValue)
Arguments
| Argument | Description |
|---|---|
| JSON | JSONArray. |
| Index | Index in the JSONArray. Indexes are zero based. |
| DefaultReturnValue | Value to return if the index is out of range. If not specified, the default value is null. |
Return value
| Value | Description |
|---|---|
| Value | Value of the index from the JSONArray. If the index is out of range, the default return value is returned. |
Example
' Returns 2
intVal = JSONArrayGetValue("[1,2,\"three\"]", 1, null)
PrintLn("Should be 2: " & intVal)
' Returns -1
defaultVal = JSONArrayGetValue("[1,2,\"three\"]", 3, -1)
PrintLn("Should be -1: " & defaultVal)